﻿/*
 * Created by BAC IT Deustche Bank
 * User: Sergio Vasquez
 * Date: 5/12/2009
 * Time: 8:31 AM
 * 
 * Description:
 * 
 */
using IScheduler.Core.Schedule;
using System;
using System.Collections.Generic;
using DotNetOpenMail;
using IScheduler.Core;
using IScheduler.Core.Business;
using IScheduler.Core.Persistence;
using IScheduler.Core.Services;
using log4net;

namespace IScheduler.Test
{
	class Program
	{
		public Program()
		{
			this.TestData();
			
		}
		
		private void TestData()
		{
			ScheduleMonitorBusiness business = new ScheduleMonitorBusiness();
			IList<ScheduleTimer> list = new List<ScheduleTimer>();
			business.BuildSchedules(ref list);
		}

        private void TestLogging()
        {
            log4net.GlobalContext.Properties["id_task"] = "69";
            log4net.GlobalContext.Properties["guid_session"] = UtilService.GenerateSessionGuid();

            LoggingService.Debug("Testing...");
            LoggingService.Info(SettingService.Settings.WindowServiceDescription);
            LoggingService.Warn("Warning message");
            LoggingService.Fatal("Fatal Message");
            LoggingService.Error("Error message");

            try
            {
                int a = 16, b = 0;
                a = a / b;
            }
            catch (Exception e)
            {
                LoggingService.Error("Error because of math.", e);
            }
        }

        private void TestEmail()
        {
            EmailMessage emailMessage = new EmailMessage();

            emailMessage.FromAddress = new EmailAddress("welcome.idea@gmail.com",
                "My Idea");

            emailMessage.AddToAddress(new EmailAddress("welcome.idea@gmail.com",
                "My Idea To"));

            emailMessage.Subject = "Missed you";

            emailMessage.TextPart = new TextAttachment("Just checking where " +
                "you were last night.\r\nSend me a note!\r\n\r\n-Charles");

            emailMessage.HtmlPart = new HtmlAttachment("<html><body>" +
                "<p>Just checking up on where you were last night.</p>\r\n" +
                "<p>Send me a note!</p>\r\n\r\n" +
                "<p>-Charles</p></body></html>");

            emailMessage.Send(new SmtpServer("localhost"));
        }

	
		public static void Main(string[] args)
		{
			new Program();

            Console.ReadKey();
		}
	}
}